package com.elephant.createBan.supplierCreateBean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.GenericBeanDefinition;

import java.util.function.Supplier;

/**
 * @author 林
 * @create 2025-06-16 10:27
 */
public class SupplerBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
		BeanDefinition user = beanFactory.getBeanDefinition("user");

		GenericBeanDefinition genericBeanDefinition=(GenericBeanDefinition) user;

		genericBeanDefinition.setInstanceSupplier(CreateSupplerUser::createUser);


	}
}
